package YAPserver.behaviours;

import YAPserver.collisionEngine.*;
import YAPserver.gameObjects.Line;

/**
 * This class will allow the ball to be reflected like light hitting a mirror.
 * @author Daniel
 *
 */
public class BounceMirror extends BounceAbstract{

	@Override
	protected double calcNewAngle(Ball ball, Wall wall){
		Line tempLine = wall.getLine();
		Line ballLine = ball.getLine();
		
		double objectAngle = tempLine.getAngle();
		double ballAngle = ballLine.getAngle();
		
		double angle = objectAngle;
		if(angle >= Math.PI ){
			angle = angle-Math.PI;
		}
		double newAngle = 2*(objectAngle)-ballAngle;
		if(newAngle > 2*Math.PI){
			newAngle = newAngle - 2*Math.PI;
		}
		if(newAngle < 0){
			newAngle = newAngle + 2*Math.PI;
		}
		return newAngle;
	}
}
